package com.czbank.financing.controller;

import com.czbank.financing.Entity.Power;
import com.czbank.financing.Entity.Product;
import com.czbank.financing.service.PowerService;
import com.czbank.financing.service.ProductService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Date;

/**
 * @Auther: thinkpad
 * @Date: 2019/7/13 02:17
 * @Description:
 */
@RestController
@RequestMapping("/Power")
public class PowerController {
    @Autowired
    private PowerService powerService;
    @RequestMapping("/ProductInfo")
    public Object PowerInfo(int pid){
        return powerService.SelectPowerInfo(pid);
    }

    @RequestMapping("/UpdatePower")
    public Object UpdatePower(int pid ,int powerType){
        if(powerService.UpdatePowerInfo(pid,powerType )==0){

            return "fail";
        }
        else {
            return "success";
        }
    }

    @RequestMapping("/DeletePower")
    public Object DeleteProduct(int powerType){
        if(powerService.DeletePowerInfo(powerType)==0){

            return "fail";
        }
        else {
            return "success";
        }
    }

    @RequestMapping("/InsertPower")
    public Object InsertPowerInfo(int powerType,  Date creationtime){
        if (powerService.InsertPowerInfo(powerType, creationtime)==0){
            return "Inserfail";
        }
        else {
            return "Insersuccess";
        }

    }

}
